package com.easyjava.bean;

import com.alibaba.fastjson.JSON;
import com.easyjava.utils.JsonUtils;
import com.easyjava.utils.PropertiesUtils;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * @Author: 小闹心
 * @Description: 常量池
 * @DateTime: 2024/11/16 10:16
 **/
public class Constants {
    // 判断枚举是否已经创建
    public static final Set<String> CREATED_ENUMS = new HashSet<>();

    public static String DB_COMMENT_ENUM_INTERVAL;

    public static Boolean IGNORE_TABLE_PREFIX;
    public static String SUFFIX_BEAN_QUERY;
    public static String SUFFIX_BEAN_QUERY_FUZZY;
    public static String SUFFIX_BEAN_QUERY_TIME_START;
    public static String SUFFIX_BEAN_QUERY_TIME_END;
    public static String SUFFIX_MAPPER;

    public static Boolean KNIFE4J_ENABLE;

    public static String PATH_JAVA = "java";
    public static String PATH_RESOURCES = "resources";

    public static String PATH_BASE;
    public static String PATH_PO;
    public static String PACKAGE_BASE;

    public static String PACKAGE_PO;
    public static String PACKAGE_UTILS;
    public static String PATH_UTILS;
    public static String PACKAGE_ENUMS;
    public static String PATH_ENUMS;
    public static String PACKAGE_QUERY;
    public static String PATH_QUERY;
    public static String PACKAGE_MAPPER;
    public static String PATH_MAPPER;
    public static String PATH_MAPPER_XML;
    public static String PACKAGE_SERVICE;
    public static String PATH_SERVICE;
    public static String PACKAGE_SERVICE_IMPL;
    public static String PATH_SERVICE_IMPL;
    public static String PACKAGE_VO;
    public static String PATH_VO;
    public static String PACKAGE_COMMON;
    public static String PATH_COMMON;
    public static String PACKAGER_EXCEPTION;
    public static String PATH_EXCEPTION;
    public static String PACKAGE_CONTROLLER;
    public static String PATH_CONTROLLER;
    public static String PACKAGE_CONFIG;
    public static String PATH_CONFIG;

    public static String AUTHOR_COMMENT;

    // 需要忽略的属性
    public static String[] IGNORE_BEAN_TOJSON_FIELDS;
    public static String IGNORE_BEAN_TOJSON_EXPRESSION;
    public static String IGNORE_BEAN_TOJSON_CLASS;
    //日期序列化和反序列化
    public static String BEAN_DATE_FORMAT_EXPRESSION;
    public static String BEAN_DATE_FORMAT_CLASS;
    public static String BEAN_DATE_PARSE_EXPRESSION;
    public static String BEAN_DATE_PARSE_CLASS;

    public static String[] CREATE_CASCADE_QUERY;

    static {

        DB_COMMENT_ENUM_INTERVAL = PropertiesUtils.getString("db.comment.enum.interval");

        IGNORE_TABLE_PREFIX = Boolean.valueOf(PropertiesUtils.getString("ignore.table.prefix"));
        SUFFIX_BEAN_QUERY = PropertiesUtils.getString("suffix.bean.query");
        SUFFIX_BEAN_QUERY_FUZZY = PropertiesUtils.getString("suffix.bean.query.fuzzy");
        SUFFIX_BEAN_QUERY_TIME_START = PropertiesUtils.getString("suffix.bean.query.time.start");
        SUFFIX_BEAN_QUERY_TIME_END = PropertiesUtils.getString("suffix.bean.query.time.end");
        SUFFIX_MAPPER = PropertiesUtils.getString("suffix.mapper");

        KNIFE4J_ENABLE = Boolean.valueOf(PropertiesUtils.getString("knife4j.enable"));


        PACKAGE_BASE = PropertiesUtils.getString("package.base");
        PACKAGE_PO = PACKAGE_BASE + "." + PropertiesUtils.getString("package.po");
        PACKAGE_VO = PACKAGE_BASE + "." + PropertiesUtils.getString("package.vo");
        PACKAGE_UTILS = PACKAGE_BASE + "." + PropertiesUtils.getString("package.utils");
        PACKAGE_ENUMS = PACKAGE_BASE + "." + PropertiesUtils.getString("package.enums");
        PACKAGE_QUERY = PACKAGE_BASE + "." + PropertiesUtils.getString("package.query");
        PACKAGE_MAPPER = PACKAGE_BASE + "." + PropertiesUtils.getString("package.mapper");
        PACKAGE_SERVICE = PACKAGE_BASE + "." + PropertiesUtils.getString("package.service");
        PACKAGE_SERVICE_IMPL = PACKAGE_BASE + "." + PropertiesUtils.getString("package.service.impl");
        PACKAGE_COMMON = PACKAGE_BASE + "." + PropertiesUtils.getString("package.common");
        PACKAGER_EXCEPTION = PACKAGE_BASE + "." + PropertiesUtils.getString("package.exception");
        PACKAGE_CONTROLLER = PACKAGE_BASE + "." + PropertiesUtils.getString("package.controller");
        PACKAGE_CONFIG = PACKAGE_BASE + "." + PropertiesUtils.getString("package.config");

        PATH_BASE = PropertiesUtils.getString("path.base");

        PATH_MAPPER_XML = PATH_BASE + PATH_RESOURCES + "/" + PACKAGE_MAPPER.replace(".","/");

        PATH_BASE = PATH_BASE + PATH_JAVA;

        PATH_PO = PATH_BASE + "/" + PACKAGE_PO.replace(".", "/");
        PATH_VO = PATH_BASE + "/" + PACKAGE_VO.replace(".", "/");
        PATH_UTILS = PATH_BASE + "/" + PACKAGE_UTILS.replace(".", "/");
        PATH_ENUMS = PATH_BASE + "/" + PACKAGE_ENUMS.replace(".", "/");
        PATH_QUERY = PATH_BASE + "/" + PACKAGE_QUERY.replace(".", "/");
        PATH_MAPPER = PATH_BASE + "/" + PACKAGE_MAPPER.replace(".", "/");
        PATH_SERVICE = PATH_BASE + "/" + PACKAGE_SERVICE.replace(".", "/");
        PATH_SERVICE_IMPL = PATH_BASE + "/" + PACKAGE_SERVICE_IMPL.replace(".", "/");
        PATH_COMMON = PATH_BASE + "/" + PACKAGE_COMMON.replace(".", "/");
        PATH_EXCEPTION = PATH_BASE + "/" + PACKAGER_EXCEPTION.replace(".", "/");
        PATH_CONTROLLER = PATH_BASE + "/" + PACKAGE_CONTROLLER.replace(".", "/");
        PATH_CONFIG = PATH_BASE + "/" + PACKAGE_CONFIG.replace(".", "/");


        AUTHOR_COMMENT = PropertiesUtils.getString("author.comment");

        IGNORE_BEAN_TOJSON_FIELDS = PropertiesUtils.getString("ignore.bean.tojson.fields").split(",");
        IGNORE_BEAN_TOJSON_EXPRESSION = PropertiesUtils.getString("ignore.bean.tojson.expression");
        IGNORE_BEAN_TOJSON_CLASS = PropertiesUtils.getString("ignore.bean.tojson.class");


        BEAN_DATE_FORMAT_EXPRESSION = PropertiesUtils.getString("bean.date.format.expression");
        BEAN_DATE_FORMAT_CLASS = PropertiesUtils.getString("bean.date.format.class");
        BEAN_DATE_PARSE_EXPRESSION = PropertiesUtils.getString("bean.date.parse.expression");
        BEAN_DATE_PARSE_CLASS = PropertiesUtils.getString("bean.date.parse.class");

        CREATE_CASCADE_QUERY = JSON.parseArray(PropertiesUtils.getString("create.cascade.query")).toArray(new String[0]);
    }
    public static final String[] SQL_DATE_TIMES_TYPES = {"datetime", "timestamp"};
    public static final String[] SQL_DATE_TYPES = {"date"};
    public static final String[] SQL_DECIMAL_TYPES = {"decimal", "double", "float"};
    public static final String[] SQL_STRING_TYPES = {"varchar", "char", "text", "longtext", "mediumtext"};
    public static final String[] SQL_INTEGER_TYPES = {"int", "tinyint"};

    public static final String[] SQL_LONG_TYPES = {"bigint","mediumint unsigned","mediumint"};

    public static final String[] SQL_INTEGER_UNSIGNED_TYPES = {"int unsigned", "tinyint unsigned","smallint unsigned"};

    public static void main(String[] args) {
//        System.out.println(PACKAGE_PO);
        System.out.println(PATH_MAPPER_XML);
    }
}
